/*     */ package com.cr.quartz.controller;
/*     */ 
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.exception.job.TaskException;
/*     */ import com.cr.common.utils.MyStringUtils;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import com.cr.quartz.domain.SysJob;
/*     */ import com.cr.quartz.service.ISysJobService;
/*     */ import com.cr.quartz.util.CronUtils;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.quartz.SchedulerException;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.validation.annotation.Validated;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.RequestParam;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/monitor/job"})
/*     */ public class SysJobController extends BaseController {
/*  38 */   private String prefix = "monitor/job";
/*     */   
/*     */   @Autowired
/*     */   private ISysJobService jobService;
/*     */   
/*     */   @RequiresPermissions({"monitor:job:view"})
/*     */   @GetMapping
/*     */   public String job() {
/*  47 */     return this.prefix + "/job";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"monitor:job:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(SysJob job) {
/*  55 */     startPage();
/*  56 */     List<SysJob> list = this.jobService.selectJobList(job);
/*  57 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.EXPORT)
/*     */   @RequiresPermissions({"monitor:job:export"})
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(SysJob job) {
/*  66 */     List<SysJob> list = this.jobService.selectJobList(job);
/*  67 */     ExcelUtil<SysJob> util = new ExcelUtil(SysJob.class);
/*  68 */     return util.exportExcel(list, "定时任务");
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.DELETE)
/*     */   @RequiresPermissions({"monitor:job:remove"})
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) throws SchedulerException {
/*  77 */     this.jobService.deleteJobByIds(ids);
/*  78 */     return success();
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"monitor:job:detail"})
/*     */   @GetMapping({"/detail/{jobId}"})
/*     */   public String detail(@PathVariable("jobId") Long jobId, ModelMap mmap) {
/*  85 */     mmap.put("name", "job");
/*  86 */     mmap.put("job", this.jobService.selectJobById(jobId));
/*  87 */     return this.prefix + "/detail";
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.UPDATE)
/*     */   @RequiresPermissions({"monitor:job:changeStatus"})
/*     */   @PostMapping({"/changeStatus"})
/*     */   @ResponseBody
/*     */   public AjaxResult changeStatus(SysJob job) throws SchedulerException {
/*  99 */     SysJob newJob = this.jobService.selectJobById(job.getJobId());
/* 100 */     newJob.setStatus(job.getStatus());
/* 101 */     return toAjax(this.jobService.changeStatus(newJob));
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.UPDATE)
/*     */   @RequiresPermissions({"monitor:job:changeStatus"})
/*     */   @PostMapping({"/run"})
/*     */   @ResponseBody
/*     */   public AjaxResult run(SysJob job) throws SchedulerException {
/* 113 */     this.jobService.run(job);
/* 114 */     return success();
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/* 123 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.INSERT)
/*     */   @RequiresPermissions({"monitor:job:add"})
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(@Validated SysJob job) throws SchedulerException, TaskException {
/* 135 */     if (!CronUtils.isValid(job.getCronExpression()))
/* 137 */       return error("新增任务'" + job.getJobName() + "'失败，Cron表达式不正确"); 
/* 139 */     if (MyStringUtils.containsIgnoreCase(job.getInvokeTarget(), "rmi://"))
/* 141 */       return error("新增任务'" + job.getJobName() + "'失败，目标字符串不允许'rmi://'调用"); 
/* 143 */     if (MyStringUtils.containsIgnoreCase(job.getInvokeTarget(), "ldap://"))
/* 145 */       return error("新增任务'" + job.getJobName() + "'失败，目标字符串不允许'ldap://'调用"); 
/* 147 */     if (MyStringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), (CharSequence[])new String[] { "http://", "https://" }))
/* 149 */       return error("新增任务'" + job.getJobName() + "'失败，目标字符串不允许'http(s)//'调用"); 
/* 151 */     return toAjax(this.jobService.insertJob(job));
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{jobId}"})
/*     */   public String edit(@PathVariable("jobId") Long jobId, ModelMap mmap) {
/* 160 */     mmap.put("job", this.jobService.selectJobById(jobId));
/* 161 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @Log(title = "定时任务", businessType = BusinessType.UPDATE)
/*     */   @RequiresPermissions({"monitor:job:edit"})
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException {
/* 173 */     if (!CronUtils.isValid(job.getCronExpression()))
/* 175 */       return error("修改任务'" + job.getJobName() + "'失败，Cron表达式不正确"); 
/* 177 */     if (MyStringUtils.containsIgnoreCase(job.getInvokeTarget(), "rmi://"))
/* 179 */       return error("修改任务'" + job.getJobName() + "'失败，目标字符串不允许'rmi://'调用"); 
/* 181 */     if (MyStringUtils.containsIgnoreCase(job.getInvokeTarget(), "ldap://"))
/* 183 */       return error("修改任务'" + job.getJobName() + "'失败，目标字符串不允许'ldap://'调用"); 
/* 185 */     if (MyStringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), (CharSequence[])new String[] { "http://", "https://" }))
/* 187 */       return error("修改任务'" + job.getJobName() + "'失败，目标字符串不允许'http(s)//'调用"); 
/* 189 */     return toAjax(this.jobService.updateJob(job));
/*     */   }
/*     */   
/*     */   @PostMapping({"/checkCronExpressionIsValid"})
/*     */   @ResponseBody
/*     */   public boolean checkCronExpressionIsValid(SysJob job) {
/* 199 */     return this.jobService.checkCronExpressionIsValid(job.getCronExpression());
/*     */   }
/*     */   
/*     */   @GetMapping({"/cron"})
/*     */   public String cron() {
/* 208 */     return this.prefix + "/cron";
/*     */   }
/*     */   
/*     */   @GetMapping({"/queryCronExpression"})
/*     */   @ResponseBody
/*     */   public AjaxResult queryCronExpression(@RequestParam(value = "cronExpression", required = false) String cronExpression) {
/* 218 */     if (this.jobService.checkCronExpressionIsValid(cronExpression)) {
/* 220 */       List<String> dateList = CronUtils.getRecentTriggerTime(cronExpression);
/* 221 */       return success(dateList);
/*     */     } 
/* 225 */     return error("表达式无效");
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-quartz-4.7.0.jar!\com\cr\quartz\controller\SysJobController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */